package com.zj.fx.service;

import java.util.List;
import java.util.Arrays;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import cn.hutool.core.util.StrUtil;
import com.zj.fx.common.base.BaseService;
import com.zj.fx.common.support.ConvertUtil;
import com.zj.fx.mapper.auto.AutoOriimportRecordMapper;
import com.zj.fx.model.auto.AutoOriimportRecord;
import com.zj.fx.model.auto.AutoOriimportRecordExample;
import com.zj.fx.model.custom.Tablepar;
import com.zj.fx.util.SnowflakeIdWorker;
import com.zj.fx.util.StringUtils;

/**
 * 月度数据导入原始数据结果统计台账 AutoOriimportRecordService
 * @Title: AutoOriimportRecordService.java 
 * @Package com.zj.fx.service 
 * @author SQL_自动生成
 * @email ${email}
 * @date 2024-02-26 10:23:36  
 **/
@Service
public class AutoOriimportRecordService implements BaseService<AutoOriimportRecord, AutoOriimportRecordExample> {
    @Autowired
    private AutoOriimportRecordMapper autoOriimportRecordMapper;

                                                                            
    /**
     * 分页查询
     * @param pageNum
     * @param pageSize
     * @return
     */
    public PageInfo<AutoOriimportRecord> list(Tablepar tablepar,AutoOriimportRecord autoOriimportRecord) {
            AutoOriimportRecordExample testExample = new AutoOriimportRecordExample();
        //搜索
        if (StrUtil.isNotEmpty(tablepar.getSearchText())) {//小窗体
            testExample.createCriteria().andLikeQuery2(tablepar.getSearchText());
        } else {//大搜索
            testExample.createCriteria().andLikeQuery(autoOriimportRecord);
        }
        //表格排序
        //if(StrUtil.isNotEmpty(tablepar.getOrderByColumn())) {
        //	testExample.setOrderByClause(StringUtils.toUnderScoreCase(tablepar.getOrderByColumn()) +" "+tablepar.getIsAsc());
        //}else{
        //	testExample.setOrderByClause("id ASC");
        //}
        PageHelper.startPage(tablepar.getPage(), tablepar.getLimit());
        List<AutoOriimportRecord> list = autoOriimportRecordMapper.selectByExample(testExample);
        PageInfo<AutoOriimportRecord> pageInfo = new PageInfo<AutoOriimportRecord>(list);
        return pageInfo;
    }
    
        @Override
        public int deleteByPrimaryKey(String ids) {
            
                List<String> lista = ConvertUtil.toListStrArray(ids);
                    AutoOriimportRecordExample example = new AutoOriimportRecordExample();
                example.createCriteria().andIdIn(lista);
                return autoOriimportRecordMapper.deleteByExample(example);

            
        }


        @Override
        public AutoOriimportRecord selectByPrimaryKey(String id) {
            
                return autoOriimportRecordMapper.selectByPrimaryKey(id);
            
        }


        @Override
        public int updateByPrimaryKeySelective(AutoOriimportRecord record) {
            return autoOriimportRecordMapper.updateByPrimaryKeySelective(record);
        }

    
    /**
     * 添加
     */
    @Override
    public int insertSelective(AutoOriimportRecord record) {
        
            //添加雪花主键id
            record.setId(SnowflakeIdWorker.getUUID());

        
        return autoOriimportRecordMapper.insertSelective(record);
    }


    @Override
    public int updateByExampleSelective(AutoOriimportRecord record, AutoOriimportRecordExample example) {

        return autoOriimportRecordMapper.updateByExampleSelective(record, example);
    }


    @Override
    public int updateByExample(AutoOriimportRecord record, AutoOriimportRecordExample example) {

        return autoOriimportRecordMapper.updateByExample(record, example);
    }

    @Override
    public List<AutoOriimportRecord> selectByExample(AutoOriimportRecordExample example) {

        return autoOriimportRecordMapper.selectByExample(example);
    }


    @Override
    public long countByExample(AutoOriimportRecordExample example) {

        return autoOriimportRecordMapper.countByExample(example);
    }


    @Override
    public int deleteByExample(AutoOriimportRecordExample example) {

        return autoOriimportRecordMapper.deleteByExample(example);
    }


}
